var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
    })(t, e);
}, function(t, e) {
    function n() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (n.prototype = e.prototype, 
    new n());
}), a = this && this.__decorate || function(t, e, o, n) {
    var i, s = arguments.length, a = s < 3 ? e : null === n ? n = Object.getOwnPropertyDescriptor(e, o) : n;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) a = Reflect.decorate(t, e, o, n); else for (var c = t.length - 1; 0 <= c; c--) (i = t[c]) && (a = (s < 3 ? i(a) : 3 < s ? i(e, o, a) : i(e, o)) || a);
    return 3 < s && a && Object.defineProperty(e, o, a), a;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("GameConfig"), s = e("GameData"), c = e("AudioManager"), l = e("DataManager"), d = e("EggsManager"), u = e("LoadManager"), p = e("UIManager"), h = e("WebManager"), f = e("Global"), g = cc._decorator, m = g.ccclass, y = g.property, v = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.target = null, t.btnNode = null, t.touchArea = null, t.shadow = null, t.touchId = null, 
        t.isCheck = !1, t.isCheck2 = !1, t.count = 0, t.total = 10, t.idx = 8, t.pos = cc.v2(), 
        t.originPos = cc.v2(), t;
    }
    return i(t, e), t.prototype.onLoad = function() {
        r.GC.isVaild("eggsSans") || -1 != d.default.getInstance().checkEggGun(this.idx) ? this.node.destroy() : (this.init(), 
        this.node.on("follow_success", this.doReward, this));
    }, t.prototype.onEnable = function() {
        -1 == d.default.getInstance().checkEggGun(this.idx) && this.addTouchEvent(), this.btnNode && (this.btnNode.active = !0);
    }, t.prototype.onDisable = function() {
        this.removeTouchEvent(), this.btnNode && (this.btnNode.active = !1);
    }, t.prototype.onDestroy = function() {}, t.prototype.onClick = function() {
        var e = this;
        -1 == d.default.getInstance().checkEggGun(this.idx) && (!GA.isPlatform([ GA.Platform.ByteDance, GA.Platform.Kwaigame ]) || s.GD.isFollow ? this.doReward() : p.default.getInstance().loadPnl("eggsTips").then(function(t) {
            t && (t.target = e.node);
        }));
    }, t.prototype.doReward = function() {
        var t, e, o = this;
        h.default.getInstance().sentLog("获得武器彩蛋id:" + this.idx), c.default.getInstance().playAudio("皮肤出现"), 
        this.shadow.parent = cc.Canvas.instance.node, this.shadow.active = !0;
        var n = new cc.Node().addComponent(sp.Skeleton);
        0 < f.G.eggGunModelList.filter(function(t) {
            return t.id == o.idx;
        }).length && p.default.getInstance().loadPopPnl("egg_reward", {
            type: f.RewardType.ARM,
            idx: this.idx,
            scale: 1.3
        }, function() {
            o.shadow.parent = o.node, o.shadow.active = !1, n.setCompleteListener(null), n.node.destroy(), 
            o.target.setPosition(o.pos);
        }), this.removeTouchEvent(), d.default.getInstance().updateEggGun(this.idx), -17 == s.GD.personIdx ? s.GD.gunIdx = 1008 : null === (e = null === (t = GA.PA) || void 0 === t ? void 0 : t.showToast) || void 0 === e || e.call(t, {
            title: "只有杉斯才可以使用龙骨炮",
            icon: "none"
        }), s.GD.eggsHintState = 1, l.default.getInstance().save();
    }, t.prototype.start = function() {
        this.pos = this.target.getPosition();
    }, t.prototype.init = function() {
        this.originPos = this.target.getPosition(), this.btnNode = new cc.Node(), u.default.getInstance().loadSpriteFrame({
            url: "image/ui/骨头@2x",
            sprite: this.btnNode.addComponent(cc.Sprite)
        }), this.btnNode.scale = .4, this.btnNode.zIndex = -1, this.btnNode.setPosition(this.originPos), 
        this.btnNode.parent = this.target.parent;
    }, t.prototype.addTouchEvent = function() {
        this.touchArea.on(cc.Node.EventType.TOUCH_START, this.touchStartHandler, this), 
        this.touchArea.on(cc.Node.EventType.TOUCH_MOVE, this.touchMoveHandler, this), this.touchArea.on(cc.Node.EventType.TOUCH_END, this.touchEndHandler, this), 
        this.touchArea.on(cc.Node.EventType.TOUCH_CANCEL, this.touchEndHandler, this);
    }, t.prototype.removeTouchEvent = function() {
        this.touchArea.off(cc.Node.EventType.TOUCH_START, this.touchStartHandler, this), 
        this.touchArea.off(cc.Node.EventType.TOUCH_MOVE, this.touchMoveHandler, this), this.touchArea.off(cc.Node.EventType.TOUCH_END, this.touchEndHandler, this), 
        this.touchArea.off(cc.Node.EventType.TOUCH_CANCEL, this.touchEndHandler, this);
    }, t.prototype.touchStartHandler = function(t) {
        null == this.touchId && (this.touchId = t.getID()), this.touchId == t.getID() && (t = t.getLocation(), 
        t = this.target.convertToNodeSpaceAR(t), Math.abs(t.x) <= this.target.width / 2 && Math.abs(t.y) <= this.target.height / 2 && (this.isCheck = !0));
    }, t.prototype.touchMoveHandler = function(t) {
        cc.log(t.getID()), this.touchId == t.getID() && this.isCheck && this.target.setPosition(this.target.parent.convertToNodeSpaceAR(t.getLocation()));
    }, t.prototype.touchEndHandler = function(t) {
        var e;
        this.touchId = null, this.isCheck ? this.isCheck = !1 : (e = t.getLocation(), e = this.btnNode.convertToNodeSpaceAR(e), 
        Math.abs(e.x) <= this.btnNode.width / 2 && Math.abs(e.y) <= this.btnNode.height / 2 && (cc.tween(this.btnNode).to(.1, {
            scale: .44
        }).to(.1, {
            scale: .4
        }).start(), this.onClick(t)));
    }, a([ y(cc.Node) ], t.prototype, "target", void 0), a([ y(cc.Node) ], t.prototype, "touchArea", void 0), 
    a([ y(cc.Node) ], t.prototype, "shadow", void 0), a([ m ], t);
}(cc.Component);

n.default = v;